package com.jkoss.action.jy;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jkoss.biz.jy.InterviewActionBiz;
import com.jkoss.biz.jy.StucmpjobBiz;
import com.jkoss.pojo.jy.Interview;
import com.jkoss.pojo.jy.Stucmpjob;
import com.jkoss.tool.Page;

@Controller
@RequestMapping("/jy")
public class InterviewAction {
   
	@Autowired
	private InterviewActionBiz itvbiz;
	
	@Autowired
	private StucmpjobBiz scjBiz;
	
	@RequestMapping("listItv")
	public String listItv(HttpServletRequest req,Page<Interview> page){
		if(page==null){
			page=new Page<Interview>();
		}
		page.setResults(itvbiz.listPageItv(page));
		
		req.setAttribute("page", page);
		
		//公司名和岗位名
		List<Stucmpjob> gws=scjBiz.listGwAndCp();
		req.setAttribute("gws", gws);
		//学生名字
		
		return "listItv.jsp";
		
	}
	
	@RequestMapping("addItv")
	public String addItv(HttpServletRequest req,Interview itv){
		
		String msg=itvbiz.addItv(itv);
		req.setAttribute("msg", msg);
		
		return listItv(req,null);
	}
	
	@RequestMapping("delItv")
	public String delItv(HttpServletRequest req,Integer stumsid){
		
		String msg=itvbiz.delItv(stumsid);
		
		req.setAttribute("msg", msg);
		
		return listItv(req,null);
		
	}
	
	@RequestMapping("toUpItv")
	public String toUpItv(HttpServletRequest req,Integer stumsid){
		
		Interview itv=itvbiz.oneItv(stumsid);
		req.setAttribute("itv", itv);
		List<Stucmpjob> gws=scjBiz.listGwAndCp();
		req.setAttribute("gws", gws);
		return "upItv.jsp";
	}
	
	@RequestMapping("upItv")
	public String upItv(HttpServletRequest req,Interview itv){
		
		String msg=itvbiz.upItv(itv);
		req.setAttribute("msg", msg);
		return listItv(req,null);
		
	}
}
